<?php
class App_Module_Admin_Component_Articles_Tpl_Editform extends App_Module_Admin_Tpl_Block_Editform
{
	protected $_form = 'entity/article';
	
	public function GetForm($ctrlName, $blog, $entry)
	{
        $this->ctrlName = $ctrlName;
        $this->blog = $blog;
        $this->entry = $entry;

		return $this->CreateForm($entry);
	}

	protected function GetActionUrl()
	{
		return array('module' => 'admin', 'ctrl' => $this->ctrlName, 'action' => 'save', 'blog' => $this->blog->GetId(), 'id' => $this->entry->GetId());
	}
	
	protected function GetBackUrl()
	{
		return array('module' => 'admin', 'ctrl' => $this->ctrlName, 'action' => 'list', 'blog' => $this->blog->GetId());
	}
	
	protected function GetHeaderTitle()
	{
		if ($this->entry->GetId())
		{
			$title = Mozg_Lang::_('EDIT_ARTICLE');
		}
		else
		{
			$title = Mozg_Lang::_('ADD_ARTICLE');
		}

		return $title;
	}
	
	protected function GetHeaderIcons()
	{
        $icons[] = array(
        	'add' => array(
        					'title' => 'ADD',
        					'url' => Mozg::Router('http')->Create('module=admin&ctrl=' .$this->ctrlName. '&action=add&blog=' .$this->blog->GetId())
        					),
        );

        if ($this->entry->GetId())
        {
	        $icons[] = array(
	        	'comments' => array(
	        					'title' => 'EDIT',
	        					'url' => Mozg::Router('http')->Create('module=admin&ctrl=' .$this->ctrlName. '&action=commentslist&blog=' .$this->blog->GetId(). '&id=' .$this->entry->GetId())
	        					),
	        	'articles' => array(
	        					'title' => 'режим выбора статей по теме',
	        					'url' => Mozg::Router('http')->Create('module=admin&ctrl=' .$this->ctrlName. '&action=list&blog=' .$this->blog->GetId(). '&main_theme_id=' .$this->entry->GetId())
	        					),
	        	'delete' => array(
	        					'title' => 'DELETE_ARTICLE?',
	        					'url' => Mozg::Router('http')->Create('module=admin&ctrl=' .$this->ctrlName. '&action=del&blog=' .$this->blog->GetId(). '&id=' .$this->entry->GetId())
	        					),
	        );
        }
        
        return $icons;
	}
}